#ifndef SERVER_H
#define SERVER_H
#include <QTcpServer>
#include "../../../client/qt_messenger/network/connection.h"
class Server:public QTcpServer
{
    Q_OBJECT
public:
    explicit Server(int listenPort,QObject *parent=0);
signals:
    void newConnection(Connection  *conn);
    void recieveData(QString ip,QByteArray data);
    void notify(QString ip,int code);
public slots:
    void onSendData(QString ip,QByteArray data);
    void onCloseConnection(QString ip);
private slots:
    void onNewConnection(Connection *conn);
    void onRecieveData(QString ip,QByteArray data);
protected:
    void incomingConnection(int socketDescriptor);

private:
    void addNewConnection(Connection *conn);
    QHash<QString,Connection *> conns;
};

#endif // SERVER_H
